<template>
  <div>
    <!--预约挂号-->
    <div>
      <div class="shouye">
        <div class="blue"></div>
        <h1>添加报告</h1>
      </div>
      <br />
    </div>
    <div class="yyxx">
      <p class="yyxx_p1">报告详情</p>
      <el-card class="box-card" style="height:420px;">
        <div class="cgjc">
          <div class="cgjc_box1">
            <div class="t1">
              <p class="t1_p1">项目名称</p>
              <p class="t1_p1">检查结果</p>
              <p class="t1_p1">参考值</p>
            </div>
            <div class="t2">
              <p class="t2_p1">身高</p>
              <p class="t2_p1">
                <el-input
                  v-model="conventionList.SbloodRoutineExaminatioId"
                ></el-input>
              </p>
            </div>
            <div class="t2">
              <p class="t2_p1">体重</p>
              <p class="t2_p1">
                <el-input v-model="conventionList.liverId"></el-input>
              </p>
            </div>

            <div class="t2">
              <p class="t2_p1">血压（收缩压）</p>
              <p class="t2_p1">
                <el-input v-model="conventionList.hypertension"></el-input>
              </p>
              <p class="t2_p1">
                <el-input
                  v-model="conventionList.hypertensionReference"
                ></el-input>
              </p>
            </div>
            <div class="t2">
              <p class="t2_p1">血压（舒张压）</p>
              <p class="t2_p1">
                <el-input v-model="conventionList.hypotension"></el-input>
              </p>
              <p class="t2_p1">
                <el-input
                  v-model="conventionList.hypotensionReference"
                ></el-input>
              </p>
            </div>
          </div>
        </div>

        <div class="cgjc1">
          <div class="cgjc_box1">
            <div class="t1">
              <p class="t1_p1">项目名称</p>
              <p class="t1_p1">检验值</p>
              <p class="t1_p1">参考范围</p>
            </div>
            <div class="t2">
              <p class="t2_p1">血红蛋白</p>
              <p class="t2_p1">
                <el-input
                  v-model="bloodRoutineexaminatioList.hemoglobin"
                ></el-input>
              </p>
              <p class="t2_p1">
                <el-input v-model="hemoglobinReference"></el-input>
              </p>
            </div>
            <div class="t2">
              <p class="t2_p1">红细胞</p>
              <p class="t2_p1">
                <el-input
                  v-model="bloodRoutineexaminatioList.redBloodCell"
                ></el-input>
              </p>
              <p class="t2_p1">
                <el-input v-model="redBloodCellReference"></el-input>
              </p>
            </div>
            <div class="t2">
              <p class="t2_p1">血小板</p>
              <p class="t2_p1">
                <el-input
                  v-model="bloodRoutineexaminatioList.bloodCells"
                ></el-input>
              </p>
              <p class="t2_p1">
                <el-input v-model="bloodCellsReference"></el-input>
              </p>
            </div>
          </div>
        </div>

        <div class="anniu">
          <el-button type="primary" plain @click="baocun"
            >确定</el-button
          >
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      id: "",
      labelPosition: "right",
      formLabelAlign: {
        name: "",
        region: "",
        type: ""
      },
      medicalAppointment: [],
      thepatient: [],
      setMeal: [],
      divisiontype: [],
      campus: [],
      physicalreport: [],
      tableData: [],
      conventionList: [],
      conventionList: {
        projectName: "",
        ofPatientId: "",
        setMealId: "",
        bloodRoutineExaminatioId: "",
        liverId: "",
        hypertension: "",
        hypertensionReference: "",
        hypotension: "",
        hypotensionReference: ""
      },
      bloodRoutineexaminatioList: {
        projectName: "",
        ofPatientId: "",
        setMealId: "",
        hemoglobin: "",
        redBloodCell: "",
        bloodCells: ""
      },
      hemoglobinReference: "",
      redBloodCellReference: "",
      bloodCellsReference: ""
    };
  },
  created() {
    //接收id
    // console.log(this.id)
    this.id = localStorage.getItem("medicalAppointmentid");
    //alert(this.id)
  },
  methods: {
    quxiao() {
      this.$router.push("/tijian");
    },
    baocun() {
      this.addconvention();
      this.addBloodRoutineExaminatio();
      this.updatetjState();
    },
    //添加常规检查
    addconvention() {
      this.$axios
        .post("/record/record/blood-routine-examinatio/addconvention", {
          ofPatientId: this.thepatient.id,
          setMealId: this.setMeal.id,
          bloodRoutineExaminatioId: this.conventionList
            .bloodRoutineExaminatioId,
          liverId: this.conventionList.liverId,
          hypertension: this.conventionList.hypertension,
          hypertensionReference: this.conventionList.hypertensionReference,
          hypotension: this.conventionList.hypotension,
          hypotensionReference: this.conventionList.hypotensionReference
        })
        .then(res => {
          if (res.data.code == 20000) {
            this.$message.success(res.data.data.ok);
          } else {
            this.$message.error(res.data.data.error);
          }
        })
        .catch(res => {
          console.log("出错了");
          console.log(res);
        });
    },
    //添加血常规检查
    addBloodRoutineExaminatio() {
      // console.log(this.bloodCellsReference);
      this.$axios
        .post(
          "/record/record/blood-routine-examinatio/addBloodRoutineExaminatio",
          {
            hemoglobin: this.bloodRoutineexaminatioList.hemoglobin,
            redBloodCell: this.bloodRoutineexaminatioList.redBloodCell,
            bloodCells: this.bloodRoutineexaminatioList.bloodCells,
            hemoglobinReference: this.hemoglobinReference,
            redBloodCellReference: this.redBloodCellReference,
            bloodCellsReference: this.bloodCellsReference
          }
        )
        .then(res => {
          if (res.data.code == 20000) {
            this.$message.success(res.data.data.ok);
          } else {
            this.$message.error(res.data.data.error);
          }
        })
        .catch(res => {
          console.log("出错了");
          console.log(res);
        });
    },
    //修改状态
    updatetjState(){
      console.log(this.id)
       this.$axios
        .post("/appointment/appointment/medical-appointment/updatetjState", {
          id: this.id,
        })
        .then(res => {
          if (res.data.code == 20000) {
            this.$message.success(res.data.data.ok);
          } else {
            this.$message.error(res.data.data.error);
          }
        })
        .catch(res => {
          console.log("出错了");
          console.log(res);
        });
    }
  }
};
</script>

<style>
.shouye {
  margin-top: 10px;
}
.blue {
  width: 36px;
  height: 12px;
  background-color: blue;
  float: left;
  margin-left: 20px;
  margin-top: 6px;
  border-radius: 50px;
}
.shouye h1 {
  float: left;
  margin-top: -4px;
  margin-left: 10px;
}
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  height: 220px;
}
.hzxx {
  background-color: #e6e6e6;
}
.hzxx p {
  width: 200px;
  margin-left: -40px;
  color: #4da6ff;
}
.hzxx_box1 {
  width: 300px;
  float: left;
}
.hzxx_box2 {
  float: left;
  margin-left: 100px;
}
.yyxx {
  background-color: #e6e6e6;
}
.yyxx_p1 {
  width: 200px;
  margin-left: -40px;
  color: #4da6ff;
}
.anniu {
  width: 400px;
  height: 50px;
  margin-left: 100px;
  margin-top: 340px;
}
.cgjc {
  width: 500px;
  float: left;
}
.cgjc1 {
  width: 500px;
  float: right;
  margin-right: 150px;
}
.xcg {
  width: 500px;
  float: right;
}
.cgjc_box1 {
  float: left;
}
.cgjc_p2 {
  margin-top: -20px;
  margin-left: -20px;
  width: 200px;
  font-size: 16px;
  color: #000000;
  float: left;
}
.t1 {
  background-color: #f0f0f5;
  width: 600px;
  height: 40px;
  float: left;
}
.t1_p1 {
  font-size: 16px;
  padding-top: 12px;
  width: 200px;
  height: 40px;
  float: left;
  margin-top: -1px;
}
.t2 {
  font-size: 14px;
  width: 600px;
  height: 50px;
  float: left;
  border-bottom: 1px solid #f0f0f5;
}
.t2_p1 {
  font-size: 16px;
  padding-top: 14px;
  width: 200px;
  height: 40px;
  float: left;
  margin-top: -1px;
}
</style>
